-- wear_attrib
-- create by zhuangsl
-- 首次穿戴奖励迷宫属性（能量）

return {
    apply = function(prop, baseValue)
        -- 数量
        return prop[3];
    end,

    record = function(target, prop, path)
        return false;
    end,

    -- 穿戴装备触发
    trigger = function(who, prop, classId)
        local attrib = prop[2];
        local propId = tonumber(prop[1]);
        local v = tonumber(prop[3]);

        -- 预先处理一下
        if not EquipM.doWearTrigger(who, classId, propId, attrib) then
            return 0;
        end

        -- 增加属性
        if "opti_point" == attrib then
            -- 处理优化点
            local opti = who.dbase:query("opti_point", 0);
            opti = opti + v;

            who.dbase:set("opti_point", opti);
            EventMgr.fire(event.SOUL_COLLECT, {["amount"] = v, ["attrib"] = "opti_point" });
        else
            DungeonServiceM.addDungeonAttrib(attrib, v);
        end

        return v;
    end,

    desc = function(prop)
        local row = PropM.getRow(prop[1]);
        local desc = row.desc;

        local attrib = prop[2];

        if attrib == "opti_point" then
            desc = string.gsub(desc, "{0}", getLocStr("opti_point2"));
        else
            desc = string.gsub(desc, "{0}", DungeonServiceM.getDungeonAttribInfo(attrib, "name"));
        end

        desc = string.gsub(desc, "{1}", prop[3]);

        return desc;
    end,
};
